<% @page_title = "#{h @group.title}小组 | 多背一公斤 - 灾后学校重建计划" -%>

<% content_for :sidebar do -%>
<div class="prepend-1">
  <% if @group.has_member?(current_user) -%>
    <h4><%= link_to "写新话题", new_topic_url(@group.id) %></h4>
    <%= link_to "退出#{@group.title}小组", quit_group_url(@group), :method => :delete  %>
  <% else -%>
    <h4><%= link_to "加入#{@group.title}小组", join_group_url(@group), :method =>:put %></h4>
    <span class="tip">加入后可以发言</span>
  <% end -%>
  
  <h3 class="nt">小组管理员 <%= title_suffix %></h3>
  <%= render :partial => "/shared/users", :object => @moderators %>
  
  <h3 class="nt">小组成员 <%= title_suffix %></h3>
  <%= render :partial => "/shared/users", :object => @members %>
</div>
<% end -%>

<h3 class="nt"><%= h @group.title %>小组</h3>
<div class="bulletin">
  <%= @group.content_html %>
  
  <% if @group.editable_by?(current_user) -%>
    <p class="right"><%= link_to "修改小组介绍", edit_group_url(@group.id) %></p>
  <% end -%>
</div>

<h3 class="nt">最近的话题 <%= title_suffix %></h3>
<table border="0" cellspacing="0" cellpadding="3" class="left ol" width="100%">
  <tr>
    <th>标题</th>
    <th>作者</th>
    <th align="right">总回复</th>
    <th align="right">最后回复</th>
  </tr>
  <% @topics.each do |topic| -%>
  <tr>
    <td width="40%"><%= link_to_group_topic_page topic, :target => '_blank' %></td>
    <td width="20%"><%= link_to_user_page topic.user, :target => '_blank' %></td>
    <td class="tip" align="right"><%= topic.posts_count %></td>
    <td class="tip" width="30%" align="right">
      <% if topic.posts_count > 0 -%>
        <span class="tip"><%= topic.replied_by_user.login %>@<%= show_date topic.replied_at %></span>
      <% end -%>
    </td>
  </tr>
  <% end -%>
</table>
<%= will_paginate @topics %>
<div class="clear"></div>
